﻿/* Copyright (c) Microsoft Corporation
 * 
 * All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 * 
 * THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
 * 
 * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProximityTapper
{
    [CLSCompliant(false)]
    public interface IExtensionSubMessage
    {
        // byte array to store extension type
        byte[] ExtensionType { get; }

        // byte array to store extension data
        byte[] ExtensionData { get; }

        /// <summary>
        /// Try parsing extension sub message data
        /// </summary>
        /// <param name="data">Message Data</param>
        /// <param name="offset">
        /// Starting / current position in byte array.
        /// This is updated as the bytes are read.
        /// </param>
        /// <returns>true is successful in parsing, false otherwise</returns>
        /// <summary>
        bool TryParse(byte[] data, ref UInt32 offset);
    }

    [CLSCompliant(false)]
    public interface ISessionActivation : IMessageData
    {
        // This determines if current message is Session Activation message
        // or Session Activation Ack Message
        bool IsAck { get; }

        // byte array storing Source ID
        // Used in Session Activation Message (8 bytes)
        byte[] SourceId { get; }

        // byte array storing Activated Session Factory ID
        // Used in Session Activation Message (8 bytes)
        byte[] ActivatedSessionFactoryId { get; }

        // byte array storing Reply Channel ID
        // Used in Session Activation Message (8 bytes)
        byte[] ReplyChannelId { get; }

        // Public Key Magic Number
        // Used in Session Activation Message (32 bits)
        // Also used in Session Activation Message Ack (32 bits)
        UInt32 ECDHPublicKeyMagicNumber { get; }

        // Public key length
        // Used in Session Activation Message (32 bits)
        // Also used in Session Activation Message Ack (32 bits)
        UInt32 ECDHPublicKeyLength { get; }

        // byte array containing X param for the ECDH key
        // Used in Session Activation Message (32 bytes)
        // Also used in Session Activation Message Ack (32 bytes)
        byte[] ECDH_X { get; }

        // byte array containing Y param for the ECDH key
        // Used in Session Activation Message (32 bytes)
        // Also used in Session Activation Message Ack (32 bytes)
        byte[] ECDH_Y { get; }

        // TCP Port
        // Used in Session Activation Message Ack (16 bits)
        UInt16 TCPPort { get; }

        // RF Comm Port
        // Used in Session Activation Message Ack (8 bits)
        byte RFCOMMPort { get; }

        // Reserved word (optional)
        // Used in Session Activation Message (32 bits)
        // Also used in Session Activation Message Ack (8 bits)
        UInt32 Reserved1 { get; }

        // Reserved word 2 (optional)
        // Used in Session Activation Message (32 bits)
        // Also used in Session Activation Message Ack (32 bits)
        UInt32 Reserved2 { get; }

        // Reserved word 3 (optional)
        // Used in Session Activation Message (16 bits)
        // Also used in Session Activation Message Ack (32 bits)
        UInt32 Reserved3 { get; }

        // Reserved word 4 (optional)
        // Used in Session Activation Message Ack (16 bits)
        UInt32 Reserved4 { get; }

        // List containing extension sub message (optional)
        // Used in Session Activation Message 
        // Also used in Session Activation Message Ack
        List<IExtensionSubMessage> ExtensionList { get; }
    }
}
